package com.wuming.caiwu.filter;

import com.wuming.caiwu.core.HuiqianConstent;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hanfei on 17/4/11.
 */
public class SiteBaseFilter implements Filter {

    public void destroy() {

    }

    public void doFilter(ServletRequest sRequest, ServletResponse sResponse,
                         FilterChain fChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) sRequest;
        HttpServletResponse response = (HttpServletResponse) sResponse;
        request.setAttribute("basePath", request.getContextPath() + "/");
        request.setAttribute("allServerPath", request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/");
        request.setAttribute("staticUrl", HuiqianConstent.DOMAINNAME + "/");
        fChain.doFilter(request, response);
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }


}
